<?php

namespace App\Admin\Controllers\activity;

use App\Common\statement\CommonStatement;
use App\Models\activity\Activity;
use App\Models\activity\ActivityAdmin;
use App\Models\User;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class ActivityAdminController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '试卷';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new ActivityAdmin());
        $grid->disableExport();
        $grid->model()->latest();

        $grid->column('user.name', __('Founder'));
        $grid->column('created_at', __('Created at'));
        $grid->column('updated_at', __('Updated at'));
        $grid->actions(function ($actions) {
            $actions->disableView();
        });
        return $grid;
    }


    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new ActivityAdmin());


        $userList = User::pluck('name','id');

        $form->select('user_id', __('姓名'))->options($userList);

        $form->saving(function (Form $form) {

        });

        $form->saved(function (Form $form) {

        });

        return $form;
    }
}
